package com.rc.saas.tenant.model.acct;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.rc.saas.tenant.base.BaseModel;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

public class AcctRule extends BaseModel {
    private String statusString;

    private Long acctRuleId;

    private String tenantCode;

    private String tenantOperatorCode;

    private Long operatorStationId;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date ruleStartTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date ruleEndTime;

    private String elecRuleType;

    private String elecAcctRule;

    private String serviceAcctRule;

    private String totalRule;

    private String remark;

    private String status;

    private String createdBy;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdTime;

    private String lastUpdatedBy;

    private Date lastUpdatedTime;

    public String getStatusString() {
        Date date = new Date();
        long time = date.getTime();
        if (ruleStartTime != null && ruleEndTime.toString() != null) {
            if ("1".equals(status)) {
                return "停用";
            } else if ("0".equals(status)) {
                if (ruleStartTime.getTime() > time) {
                    return "未开始";
                } else if (ruleStartTime.getTime() < time && ruleEndTime.getTime() > time) {
                    return "进行中";
                } else if (ruleEndTime.getTime() < time) {
                    return "已结束";
                }
            }
        }

        return status;
    }

    public void setStatusString(String statusString) {
        this.statusString = statusString;
    }

    public Long getAcctRuleId() {
        return acctRuleId;
    }

    public void setAcctRuleId(Long acctRuleId) {
        this.acctRuleId = acctRuleId;
    }

    public String getTenantCode() {
        return tenantCode;
    }

    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }

    public String getTenantOperatorCode() {
        return tenantOperatorCode;
    }

    public void setTenantOperatorCode(String tenantOperatorCode) {
        this.tenantOperatorCode = tenantOperatorCode;
    }

    public Long getOperatorStationId() {
        return operatorStationId;
    }

    public void setOperatorStationId(Long operatorStationId) {
        this.operatorStationId = operatorStationId;
    }

    public Date getRuleStartTime() {
        return ruleStartTime;
    }

    public void setRuleStartTime(Date ruleStartTime) {
        this.ruleStartTime = ruleStartTime;
    }

    public Date getRuleEndTime() {
        return ruleEndTime;
    }

    public void setRuleEndTime(Date ruleEndTime) {
        this.ruleEndTime = ruleEndTime;
    }

    public String getElecRuleType() {
        return elecRuleType;
    }

    public void setElecRuleType(String elecRuleType) {
        this.elecRuleType = elecRuleType;
    }

    public String getElecAcctRule() {
        return elecAcctRule;
    }

    public void setElecAcctRule(String elecAcctRule) {
        this.elecAcctRule = elecAcctRule;
    }

    public String getServiceAcctRule() {
        return serviceAcctRule;
    }

    public void setServiceAcctRule(String serviceAcctRule) {
        this.serviceAcctRule = serviceAcctRule;
    }

    public String getTotalRule() {
        return totalRule;
    }

    public void setTotalRule(String totalRule) {
        this.totalRule = totalRule;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    public String getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public void setLastUpdatedBy(String lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    public Date getLastUpdatedTime() {
        return lastUpdatedTime;
    }

    public void setLastUpdatedTime(Date lastUpdatedTime) {
        this.lastUpdatedTime = lastUpdatedTime;
    }
}